using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows.Forms;

namespace pixtek.browser
{
  static class UnsafeNativeMethods
  {
    [System.Runtime.InteropServices.ComImport(), System.Runtime.InteropServices.Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D"),
    System.Runtime.InteropServices.InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch),
    System.Runtime.InteropServices.TypeLibType(System.Runtime.InteropServices.TypeLibTypeFlags.FHidden)]
    public interface DWebBrowserEvents2
    {
      [System.Runtime.InteropServices.DispId(250)]
      void BeforeNavigate2(
      [System.Runtime.InteropServices.In,
      System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.IDispatch)] object pDisp,
      [System.Runtime.InteropServices.In] ref object URL,
      [System.Runtime.InteropServices.In] ref object flags,
      [System.Runtime.InteropServices.In] ref object targetFrameName, [System.Runtime.InteropServices.In] ref object postData,
      [System.Runtime.InteropServices.In] ref object headers,
      [System.Runtime.InteropServices.In,
      System.Runtime.InteropServices.Out] ref bool cancel);
      [System.Runtime.InteropServices.DispId(273)]
      void NewWindow3(
      [System.Runtime.InteropServices.In, System.Runtime.InteropServices.Out] ref object pDisp,
      [System.Runtime.InteropServices.In, System.Runtime.InteropServices.Out] ref bool cancel,
      [System.Runtime.InteropServices.In] ref object flags,
      [System.Runtime.InteropServices.In] ref object URLContext,
      [System.Runtime.InteropServices.In] ref object URL);
    }

    [ComImport, Guid("BD3F23C0-D43E-11CF-893B-00AA00BDCE1A"), ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IDocHostUIHandler
    {
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int ShowContextMenu([In, MarshalAs(UnmanagedType.U4)] int dwID, [In] NativeMethods.POINT pt, [In, MarshalAs(UnmanagedType.Interface)] object pcmdtReserved, [In, MarshalAs(UnmanagedType.Interface)] object pdispReserved);
      /*
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetHostInfo([In, Out] NativeMethods.DOCHOSTUIINFO info);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int ShowUI([In, MarshalAs(UnmanagedType.I4)] int dwID, [In] UnsafeNativeMethods.IOleInPlaceActiveObject activeObject, [In] NativeMethods.IOleCommandTarget commandTarget, [In] UnsafeNativeMethods.IOleInPlaceFrame frame, [In] UnsafeNativeMethods.IOleInPlaceUIWindow doc);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int HideUI();
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int UpdateUI();
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int EnableModeless([In, MarshalAs(UnmanagedType.Bool)] bool fEnable);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int OnDocWindowActivate([In, MarshalAs(UnmanagedType.Bool)] bool fActivate);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int OnFrameWindowActivate([In, MarshalAs(UnmanagedType.Bool)] bool fActivate);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int ResizeBorder([In] NativeMethods.COMRECT rect, [In] UnsafeNativeMethods.IOleInPlaceUIWindow doc, bool fFrameWindow);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int TranslateAccelerator([In] ref NativeMethods.MSG msg, [In] ref Guid group, [In, MarshalAs(UnmanagedType.I4)] int nCmdID);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetOptionKeyPath([Out, MarshalAs(UnmanagedType.LPArray)] string[] pbstrKey, [In, MarshalAs(UnmanagedType.U4)] int dw);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetDropTarget([In, MarshalAs(UnmanagedType.Interface)] UnsafeNativeMethods.IOleDropTarget pDropTarget, [MarshalAs(UnmanagedType.Interface)] out UnsafeNativeMethods.IOleDropTarget ppDropTarget);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetExternal([MarshalAs(UnmanagedType.Interface)] out object ppDispatch);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int TranslateUrl([In, MarshalAs(UnmanagedType.U4)] int dwTranslate, [In, MarshalAs(UnmanagedType.LPWStr)] string strURLIn, [MarshalAs(UnmanagedType.LPWStr)] out string pstrURLOut);
      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int FilterDataObject(IDataObject pDO, out IDataObject ppDORet);
      */
    }


    [ComImport, SuppressUnmanagedCodeSecurity, TypeLibType(TypeLibTypeFlags.FOleAutomation | (TypeLibTypeFlags.FDual | TypeLibTypeFlags.FHidden)), Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E")]
    public interface IWebBrowser2
    {
      [DispId(100)]
      void GoBack();
      [DispId(0x65)]
      void GoForward();
      [DispId(0x66)]
      void GoHome();
      [DispId(0x67)]
      void GoSearch();
      [DispId(0x68)]
      void Navigate([In] string Url, [In] ref object flags, [In] ref object targetFrameName, [In] ref object postData, [In] ref object headers);
      [DispId(-550)]
      void Refresh();
      [DispId(0x69)]
      void Refresh2([In] ref object level);
      [DispId(0x6a)]
      void Stop();
      [DispId(200)]
      object Application { [return: MarshalAs(UnmanagedType.IDispatch)] get; }
      [DispId(0xc9)]
      object Parent { [return: MarshalAs(UnmanagedType.IDispatch)] get; }
      [DispId(0xca)]
      object Container { [return: MarshalAs(UnmanagedType.IDispatch)] get; }
      [DispId(0xcb)]
      object Document { [return: MarshalAs(UnmanagedType.IDispatch)] get; }
      [DispId(0xcc)]
      bool TopLevelContainer { get; }
      [DispId(0xcd)]
      string Type { get; }
      [DispId(0xce)]
      int Left { get; set; }
      [DispId(0xcf)]
      int Top { get; set; }
      [DispId(0xd0)]
      int Width { get; set; }
      [DispId(0xd1)]
      int Height { get; set; }
      [DispId(210)]
      string LocationName { get; }
      [DispId(0xd3)]
      string LocationURL { get; }
      [DispId(0xd4)]
      bool Busy { get; }
      [DispId(300)]
      void Quit();
      [DispId(0x12d)]
      void ClientToWindow(out int pcx, out int pcy);
      [DispId(0x12e)]
      void PutProperty([In] string property, [In] object vtValue);
      [DispId(0x12f)]
      object GetProperty([In] string property);
      [DispId(0)]
      string Name { get; }
      [DispId(-515)]
      int HWND { get; }
      [DispId(400)]
      string FullName { get; }
      [DispId(0x191)]
      string Path { get; }
      [DispId(0x192)]
      bool Visible { get; set; }
      [DispId(0x193)]
      bool StatusBar { get; set; }
      [DispId(0x194)]
      string StatusText { get; set; }
      [DispId(0x195)]
      int ToolBar { get; set; }
      [DispId(0x196)]
      bool MenuBar { get; set; }
      [DispId(0x197)]
      bool FullScreen { get; set; }
      [DispId(500)]
      void Navigate2([In] ref object URL, [In] ref object flags, [In] ref object targetFrameName, [In] ref object postData, [In] ref object headers);
      [DispId(0x1f5)]
      NativeMethods.OLECMDF QueryStatusWB([In] NativeMethods.OLECMDID cmdID);
      [DispId(0x1f6)]
      void ExecWB([In] NativeMethods.OLECMDID cmdID, [In] NativeMethods.OLECMDEXECOPT cmdexecopt, ref object pvaIn, IntPtr pvaOut);
      [DispId(0x1f7)]
      void ShowBrowserBar([In] ref object pvaClsid, [In] ref object pvarShow, [In] ref object pvarSize);
      [DispId(-525)]
      WebBrowserReadyState ReadyState { get; }
      [DispId(550)]
      bool Offline { get; set; }
      [DispId(0x227)]
      bool Silent { get; set; }
      [DispId(0x228)]
      bool RegisterAsBrowser { get; set; }
      [DispId(0x229)]
      bool RegisterAsDropTarget { get; set; }
      [DispId(0x22a)]
      bool TheaterMode { get; set; }
      [DispId(0x22b)]
      bool AddressBar { get; set; }
      [DispId(0x22c)]
      bool Resizable { get; set; }
    }

  }
}
